// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';
const apiPrefix = '/web';

/** 修改证书状态 修改证书状态 PUT /ems/control/licence */
export async function emsControllerConfigControllerUpdateLicenceState(
  body: API.EmsControllerLicenceStateForm,
  options?: { [key: string]: any },
) {
  return request<API.ApiResultBoolean>(`${apiPrefix}/ems/control/licence`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 生成序列号 生成序列号 POST /ems/control/licence */
export async function emsControllerConfigControllerLicence(
  body: API.EmsControllerLicenceForm,
  options?: { [key: string]: any },
) {
  return request<API.ApiResultBoolean>(`${apiPrefix}/ems/control/licence`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 序列号在线激活 序列号在线激活服务 POST /ems/control/licence/activation */
export async function emsControllerConfigControllerValidateActivation(
  body: API.EmsControllerLicenceActivationForm,
  options?: { [key: string]: any },
) {
  return request<API.ApiResultEmsControllerLicenceVo>(
    `${apiPrefix}/ems/control/licence/activation`,
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data: body,
      ...(options || {}),
    },
  );
}

/** EMS控制器序列号-分页查询 EMS控制器序列号记录分页查询数据 GET /ems/control/licence/page */
export async function emsControllerConfigControllerLicencePage(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.emsControllerConfigControllerLicencePageParams,
  options?: { [key: string]: any },
) {
  return request<API.ApiResultPaginationEmsControlLicence>(
    `${apiPrefix}/ems/control/licence/page`,
    {
      method: 'GET',
      params: {
        ...params,
      },
      ...(options || {}),
    },
  );
}

/** 在线验证序列号 在线验证序列号是否失效 POST /ems/control/licence/verify */
export async function emsControllerConfigControllerVerifyLicence(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.emsControllerConfigControllerVerifyLicenceParams,
  options?: { [key: string]: any },
) {
  return request<API.ApiResultEmsControllerLicenceBaseVo>(
    `${apiPrefix}/ems/control/licence/verify`,
    {
      method: 'POST',
      params: {
        ...params,
      },
      ...(options || {}),
    },
  );
}

/** 通讯参数 查询通讯参数 GET /ems/control/mqtt/config/${param0} */
export async function emsControllerConfigControllerCommConfig(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.emsControllerConfigControllerCommConfigParams,
  options?: { [key: string]: any },
) {
  const { lcId: param0, ...queryParams } = params;
  return request<API.ApiResultEmsControlCommConfigVo>(
    `${apiPrefix}/ems/control/mqtt/config/${param0}`,
    {
      method: 'GET',
      params: { ...queryParams },
      ...(options || {}),
    },
  );
}

/** EMS控制器配置-分页查询 EMS控制器配置记录分页查询数据 GET /ems/control/page */
export async function emsControllerConfigControllerConfigPage(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.emsControllerConfigControllerConfigPageParams,
  options?: { [key: string]: any },
) {
  return request<API.ApiResultPaginationEmsControllerConfigVo>(`${apiPrefix}/ems/control/page`, {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 上传配置文件 上传配置文件 POST /ems/control/upload */
export async function emsControllerConfigControllerUploadConfig(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.emsControllerConfigControllerUploadConfigParams,
  body: {},
  file?: File,
  options?: { [key: string]: any },
) {
  const formData = new FormData();

  if (file) {
    formData.append('file', file);
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele];

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''));
        } else {
          formData.append(ele, JSON.stringify(item));
        }
      } else {
        formData.append(ele, item);
      }
    }
  });

  return request<API.ApiResultEmsControllerConfigVo>(`${apiPrefix}/ems/control/upload`, {
    method: 'POST',
    params: {
      ...params,
    },
    data: formData,
    requestType: 'form',
    ...(options || {}),
  });
}
